public class Student {
    String name;

    public Student() {
        System.out.println("无参构造方法被调用啦！");
    }
    //有参构造方法
    public Student(String name) {
        this();//调用无参构造方法
        this.name = name;
    }

    public void printName() {
        System.out.println("姓名：" + name);
    }

    public static void main(String[] args) {
        Student stu = new Student("张三");
        stu.printName();
    }
}
